package com.zxzhu.joyread.Presenter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.DrawableRes;
import android.widget.ImageView;

import com.zxzhu.joyread.Model.IWelcomeModel;
import com.zxzhu.joyread.Model.WelcomeModel;
import com.zxzhu.joyread.View.IWelcomeView;
import com.zxzhu.joyread.View.LoginView;
import com.zxzhu.joyread.View.WelcomeView;

/**
 * Created by Administrator on 2017/7/28 0028.
 */

public class WelcomePresenter implements IWelcomePresenter {
    private IWelcomeView welcomeView;
    private IWelcomeModel welcomeModel;
    private Context context;
    public WelcomePresenter(WelcomeView welcomeView,Context context){
        this.context = context;
        this.welcomeView = welcomeView;
        welcomeModel = new WelcomeModel();
    }
    @Override
    public void skip() {
        Intent intent = new Intent(welcomeView.getActivity(), LoginView.class);
        welcomeView.getActivity().startActivity(intent);
        welcomeView.getActivity().finish();
    }

    @Override
    public void setGif(@DrawableRes int resorce, ImageView imageView) {
        welcomeModel.setGif(welcomeView.getActivity(), resorce, imageView, new WelcomeModel.OnPlayListener() {
            @Override
            public void onStart() {
                welcomeView.toast("  你今天阅读了吗？ ");
            }

            @Override
            public void onFinished() {
                skip();
            }
        });
    }
}
